package com.example.chatservice.webSocket;

import lombok.extern.slf4j.Slf4j;
import org.example.entity.constants.Constants;
import org.example.entity.dto.MessageSendDto;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description
 * @Author susu
 * @Date 2024/9/27
 */
@Component
@Slf4j
public class MessagePublisher {
    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendMsg(MessageSendDto messageSendDto){
        rabbitTemplate.convertAndSend(Constants.EXCHANGE_CHAT_TOPIC_NAME,Constants.ROUTING_KEY_CHAT,messageSendDto);
        log.info("消息已发送{}",messageSendDto);
    }
}
